<template>
  <view>
    <view class='startbox'>
      <text>商品评价</text><u-rate :count="5" :size="35" v-model="startnum"></u-rate>
    </view>
    <view class="evaluateBox">
      <u-input v-model="pingjiatext" placeholder="请对商品做出评价" :type="textarea"  :height="100"  />
       <view class="imgers">
         <u-upload ref="uUpload1" action="http://127.0.0.1:8000/user/upimage"  :max-size="1 * 1024 * 1024" max-count="6" :file-list="fileList"></u-upload>
       </view>
    </view>
    <view class="pinglun">
        <u-button   @click="evaluate" type="warning">提交评价</u-button>
    </view>
  </view>
</template>

<script setup>
import { ref,getCurrentInstance } from 'vue';
  import {
    orderUserStore
  } from "../../store/order.js"

  const orderStore = orderUserStore()
  import {
    onLoad
  } from '@dcloudio/uni-app';
  onLoad((option) => {
         orderid.value = option.id
  })
  const {
    proxy
  } = getCurrentInstance()
  
  //定义星星数量
 const startnum = ref(0)
 //定义评价内容
 const pingjiatext = ref("")
 //定义图片列表
 const fileList = ref([])
 //定义图片列表
 const files = ref([])
 //定义评价id
 const orderid = ref(0)
 //定义图片组
 const imagetext = ref("")
//评价
function evaluate () {
	files.value = proxy.$refs.uUpload1.lists.filter(val => {
					return val.progress == 100;
				})
  files.value = JSON.parse(JSON.stringify(files.value))
    files.value.forEach((item)=>imagetext.value+=item.url+"\n")
   const data = {
     "orderid":orderid.value,//商品id
     "imagetext":imagetext.value,
     "text":pingjiatext.value,
     "star":startnum.value
   }
   orderStore.evaluation(data)
   imagetext.value=""
   pingjiatext.value=""
}
</script>

<style lang="scss" scoped>
.startbox{
position: relative;
top: 20rpx;
margin: 0 20rpx;
padding: 0 10rpx;
height: 100rpx;
line-height: 100rpx;
font-size: 35rpx;
background-color: white;
margin-bottom: 40rpx;
}
.evaluateBox{
  background-color: white;
  margin: 0 20rpx;
  .imgers{
    margin-top: 200rpx;
  }
}
.pinglun{
 
  margin: 0 20rpx;
   margin-top: 60rpx;
}
</style>